package cn.edu.hubu.hubusmartzoohouse.controller;

import cn.edu.hubu.hubusmartzoohouse.entity.Animal;
import cn.edu.hubu.hubusmartzoohouse.entity.Stadium;
import cn.edu.hubu.hubusmartzoohouse.service.AnimalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.edu.hubu.hubusmartzoohouse.vo.ResultVo;

@RestController
@CrossOrigin
public class AnimalController {
    @Autowired
    private AnimalService animalService;


    @RequestMapping("/animal/insert")
    public ResultVo insert(Animal animal){
        ResultVo vo = animalService.addAnimal(animal);
        return vo;
    }

    @RequestMapping("/animal/list")
    public ResultVo list(){
        ResultVo vo = animalService.listAnimal();
        return vo;
    }

    @RequestMapping("/animal/delete")
    public ResultVo delete(Integer animalId){
        ResultVo vo = animalService.logicDeleteAnimal(animalId);
        return vo;
    }

    @RequestMapping("/animal/get")
    public ResultVo get(Integer animalId){
        ResultVo vo = animalService.get(animalId);
        return vo;
    }

    @RequestMapping("/animal/update")
    public ResultVo updateAnimal(Animal animal){
        ResultVo vo = animalService.modifyAnimal(animal);
        return vo;
    }

    @RequestMapping("/animal/searchById")
    public ResultVo serchAnimalById(Integer animalId){
        ResultVo vo = animalService.searchAnimalById(animalId);
        return vo;
    }

    @RequestMapping("/animal/searchByName")
    public ResultVo serchAnimalByName(String animalName){
        ResultVo vo = animalService.searchAnimalByName(animalName);
        return vo;
    }
}
